package com.wx.rabbitmq.msgadapter;

import com.wx.rabbitmq.entity.Order;
import com.wx.rabbitmq.entity.Packaged;
import org.springframework.amqp.support.converter.DefaultClassMapper;

import java.io.File;
import java.util.Map;

/**
 * @ClassName MessageAdapter
 * @Author wx
 * @Description 消息适配处理
 * @Date 2018-11-25-14:15
 */
public class MessageAdapter extends DefaultClassMapper {


    /**
     * @methodName: handleMessage
     * @author: wx
     * @description: 接收消息默认方法
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void handleMessage(byte[] messageBody) {
        System.err.println("默认方法, 消息内容:" + new String(messageBody));
    }
    /**
     * @methodName: consumeMessage
     * @author: wx
     * @description: 接收消息字节数组方法
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void consumeMessage(byte[] messageBody) {
        System.err.println("字节数组方法, 消息内容:" + new String(messageBody));
    }
    /**
     * @methodName: consumeMessage
     * @author: wx
     * @description: 接收消息字符串方法
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void consumeMessage(String messageBody) {
        System.err.println("字符串方法, 消息内容:" + messageBody);
    }

    /**
     * @methodName: method1
     * @author: wx
     * @description: 测试队列-方法名映射接收消息
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void method1(String messageBody) {
        System.err.println("method1 收到消息内容:" + new String(messageBody));
    }

    /**
     * @methodName: method2
     * @author: wx
     * @description: 测试队列-方法名映射接收消息
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void method2(String messageBody) {
        System.err.println("method2 收到消息内容:" + new String(messageBody));
    }

    /**
     * @methodName: consumeMessage
     * @author: wx
     * @description: 接收消息json(方法会被转化成map)方法
     * @param messageBody
     * @date: 2018/11/25
     * @return: void
     */
    public void consumeMessage(Map messageBody) {
        System.err.println("map方法, 消息内容:" + messageBody);
    }

    /**
     * @methodName: consumeMessage
     * @author: wx
     * @description: 接收消息对象方法
     * @param order
     * @date: 2018/11/25
     * @return: void
     */
    public void consumeMessage(Order order) {
        System.err.println("order对象, 消息内容, id: " + order.getId() +
                ", name: " + order.getName() +
                ", content: "+ order.getContent());
    }

    public void consumeMessage(Packaged pack) {
        System.err.println("package对象, 消息内容, id: " + pack.getId() +
                ", name: " + pack.getName() +
                ", content: "+ pack.getDescription());
    }

    public void consumeMessage(File file) {
        System.err.println("文件对象 方法, 消息内容:" + file.getName());
    }

}
